//   
//   LottieView.swift
//   BaseComponetKit
//   Created  by monkey on 2024/4/3
//   
//   
   

import UIKit
import Lottie

class LottieView: UIView {
    var animationView = LottieAnimationView()
    var loopMode: LottieLoopMode = .loop
    init(frame: CGRect = .zero, jsonFileName: String) {
        super.init(frame: frame)
        setupanimationView(jsonFileName: jsonFileName)
     }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - Setup

    private func setupanimationView(jsonFileName: String)  {
        animationView.animation = LottieAnimation.named(jsonFileName)
        // 设置动画视图的属性（可选）
        animationView.loopMode = loopMode
        animationView.contentMode = .scaleAspectFit
        addSubview(animationView)
        animationView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        // 播放动画
        animationView.play()
    }
}
